#ifndef BIT_WIN_ROW_COLUMN_BASES_H
#define BIT_WIN_ROW_COLUMN_BASES_H


#include <QString>
#include <QSharedDataPointer>


class QVariant;


namespace BitWin
{


class BitRange;
class PRowText;


// Bitwise table row and column base classes and shared pointers
// to tham.
// Class instances act like some "filters" for data provided by model,
// accepting some input data from the model and providing filtered
// output data for displaying.
// Row instance accepts role, data and range of bits needed
// to be displayed.
// Column accepts role, Row instance corresponding to the
// cell-to-display and data.

class Row;
class Column;


typedef QExplicitlySharedDataPointer<Row> PRow;
typedef QExplicitlySharedDataPointer<Column> PColumn;


class Row: public QSharedData
{
    // Row title
    const QString _title;
    // The index of the data word in the data
    // words sequence, corresponding to this row.
    const int _word_no;

    // Declared, but not implemented to avoid "partial assignment"
    Row& operator=(const Row&);

public:

    Row(const QString& title_, const int word_no_);
    virtual ~Row();

    // Row properties accessors
    const QString& title() const;
    int wordNo() const;

    // Key method: filter data provided by model.
    virtual QVariant data(
        int, const BitRange&, const PRowText&
    ) const =0;

    // For test purposes only
    bool operator==(const Row& rhs) const;
};


class Column: public QSharedData
{
    // Column title
    const QString _title;

    // Declared, but not implemented
    Column& operator=(const Column&);

public:

    explicit Column(const QString& title_);
    virtual ~Column();

    // Column title accessor
    const QString& title() const;

    // Key method, filter data provided by model.
    virtual QVariant data(
        int, const Row*, const PRowText&
    ) const =0;

    // For test purposes only
    bool operator==(const Column& rhs) const;
};


} // BitWin namespace end

#endif
